<?php
namespace app\home\controller;
use app\common\controller\Home;	
use think\Cache;
class Actor extends Home{
    public function show(){
		$param = zanpiancms_param_url();
		if($param['dir']){
			$param['id'] = getlist($param['dir'],'list_dir','list_id');
		}else{
			$param['dir'] = getlist($param['id'],'list_id','list_dir');
		}
        config('params',array('id'=>$param['id'],'dir'=>$param['dir'],'p'=>'[PAGE]'));
		$info=$this->Lable_List($param);
		$this->assign('param',$param);
        return $this->fetch(DS.$info['list_skin']);			
    }
    public function read(){
		$param = zanpiancms_param_url();
        $array_detail = $this->get_cache_detail($param);
		if($array_detail){
		    $this->assign('param',$param);
			$this->assign('show',$array_detail['show']);
            $this->assign('info',$array_detail['read']);			
		    return $this->fetch(DS.$array_detail['read']['actor_skin_detail']);
		}
		abort(404,'内容不存在');
    }	
   //从数据库获取数据
	private function get_cache_detail($param){
		if(empty($param['id']) && empty($param['pinyin']) && empty($param['vid'])){ return false;}
		//优先读取缓存数据
		if($GLOBALS['config']['cache']['data_cache_actor']){
			$array_detail = Cache::get('data_cache_actor_'.$param['id'].$param['pinyin']);
			if($array_detail){
				return $array_detail;
			}
		}
		//未中缓存则从数据库读取
		$where = array();
		if(!empty($param['id'])){
		    $where['actor_id'] = $param['id'];
		}		
		if(!empty($param['pinyin'])){
		    $where['vod_letters'] = $param['pinyin'];
		}
		if(!empty($param['vid'])){
		    $where['vod_id'] = $param['vid'];
		}		
		$where['actor_status'] = array('eq',1);
		$data = db('actor')->alias('actor')->join('story story','story.story_vid =actor.actor_vid','LEFT')->join('vod vod','vod.vod_id =actor.actor_vid','LEFT')->where($where)->find();
		if(!empty($data)){
			//解析标签
			$array_detail = $this->Lable_Read($data,6);
			if($GLOBALS['config']['cache']['data_cache_actor']){
				Cache::tag('data_actor')->set('data_cache_actor_'.$param['vid'].$param['pinyin'].$param['id'],$array_detail,intval($GLOBALS['config']['cache']['data_cache_actor'])); 
			}
			return $array_detail;
		}
		abort(404,'内容不存在');
	}	
}
// +----------------------------------------------------------------------
// | ZanPianCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.zanpian.com All rights reserved.
// +----------------------------------------------------------------------
// | BBS:  <http://www.feifeicms.cc>
// +----------------------------------------------------------------------
